/**
 * <copyright>
 * </copyright>
 *
 */
package org.xtext.example.mydsl.myDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.mydsl.myDsl.EnabledIP;
import org.xtext.example.mydsl.myDsl.IP;
import org.xtext.example.mydsl.myDsl.Mensaje;
import org.xtext.example.mydsl.myDsl.MyDslPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Enabled IP</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.EnabledIPImpl#getBool <em>Bool</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.EnabledIPImpl#getIp <em>Ip</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.EnabledIPImpl#getMensaje <em>Mensaje</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EnabledIPImpl extends AccionImpl implements EnabledIP
{
  /**
   * The cached value of the '{@link #getBool() <em>Bool</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBool()
   * @generated
   * @ordered
   */
  protected org.xtext.example.mydsl.myDsl.Boolean bool;

  /**
   * The cached value of the '{@link #getIp() <em>Ip</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIp()
   * @generated
   * @ordered
   */
  protected EList<IP> ip;

  /**
   * The cached value of the '{@link #getMensaje() <em>Mensaje</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMensaje()
   * @generated
   * @ordered
   */
  protected Mensaje mensaje;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected EnabledIPImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MyDslPackage.Literals.ENABLED_IP;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public org.xtext.example.mydsl.myDsl.Boolean getBool()
  {
    return bool;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetBool(org.xtext.example.mydsl.myDsl.Boolean newBool, NotificationChain msgs)
  {
    org.xtext.example.mydsl.myDsl.Boolean oldBool = bool;
    bool = newBool;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.ENABLED_IP__BOOL, oldBool, newBool);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBool(org.xtext.example.mydsl.myDsl.Boolean newBool)
  {
    if (newBool != bool)
    {
      NotificationChain msgs = null;
      if (bool != null)
        msgs = ((InternalEObject)bool).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.ENABLED_IP__BOOL, null, msgs);
      if (newBool != null)
        msgs = ((InternalEObject)newBool).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.ENABLED_IP__BOOL, null, msgs);
      msgs = basicSetBool(newBool, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.ENABLED_IP__BOOL, newBool, newBool));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<IP> getIp()
  {
    if (ip == null)
    {
      ip = new EObjectContainmentEList<IP>(IP.class, this, MyDslPackage.ENABLED_IP__IP);
    }
    return ip;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Mensaje getMensaje()
  {
    return mensaje;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMensaje(Mensaje newMensaje, NotificationChain msgs)
  {
    Mensaje oldMensaje = mensaje;
    mensaje = newMensaje;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.ENABLED_IP__MENSAJE, oldMensaje, newMensaje);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMensaje(Mensaje newMensaje)
  {
    if (newMensaje != mensaje)
    {
      NotificationChain msgs = null;
      if (mensaje != null)
        msgs = ((InternalEObject)mensaje).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.ENABLED_IP__MENSAJE, null, msgs);
      if (newMensaje != null)
        msgs = ((InternalEObject)newMensaje).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.ENABLED_IP__MENSAJE, null, msgs);
      msgs = basicSetMensaje(newMensaje, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.ENABLED_IP__MENSAJE, newMensaje, newMensaje));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.ENABLED_IP__BOOL:
        return basicSetBool(null, msgs);
      case MyDslPackage.ENABLED_IP__IP:
        return ((InternalEList<?>)getIp()).basicRemove(otherEnd, msgs);
      case MyDslPackage.ENABLED_IP__MENSAJE:
        return basicSetMensaje(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MyDslPackage.ENABLED_IP__BOOL:
        return getBool();
      case MyDslPackage.ENABLED_IP__IP:
        return getIp();
      case MyDslPackage.ENABLED_IP__MENSAJE:
        return getMensaje();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDslPackage.ENABLED_IP__BOOL:
        setBool((org.xtext.example.mydsl.myDsl.Boolean)newValue);
        return;
      case MyDslPackage.ENABLED_IP__IP:
        getIp().clear();
        getIp().addAll((Collection<? extends IP>)newValue);
        return;
      case MyDslPackage.ENABLED_IP__MENSAJE:
        setMensaje((Mensaje)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.ENABLED_IP__BOOL:
        setBool((org.xtext.example.mydsl.myDsl.Boolean)null);
        return;
      case MyDslPackage.ENABLED_IP__IP:
        getIp().clear();
        return;
      case MyDslPackage.ENABLED_IP__MENSAJE:
        setMensaje((Mensaje)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.ENABLED_IP__BOOL:
        return bool != null;
      case MyDslPackage.ENABLED_IP__IP:
        return ip != null && !ip.isEmpty();
      case MyDslPackage.ENABLED_IP__MENSAJE:
        return mensaje != null;
    }
    return super.eIsSet(featureID);
  }

} //EnabledIPImpl
